import java.util.concurrent.Semaphore;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86136
 * Date: 2025-04-27
 * Time: 20:59
 */
public class Demo55 {
    public static void main(String[] args) throws InterruptedException {
        Semaphore semaphore = new Semaphore(4);
        semaphore.acquire();
        System.out.println("获取到一个资源");
        semaphore.acquire();
        System.out.println("获取到一个资源");
        semaphore.acquire();
        System.out.println("获取到一个资源");
        semaphore.acquire();
        System.out.println("获取到一个资源");
        //Thread.sleep(1000);
        //semaphore.release();
        //将会一直阻塞等待
        semaphore.acquire();
        System.out.println("获取到一个资源");
    }
}
